package org.bjf.modules.sys.web.controller;

import java.util.List;
import org.bjf.modules.core.web.core.LoginRequired;
import org.bjf.modules.core.web.core.PageVO;
import org.bjf.modules.sys.bean.SysMenu;
import org.bjf.modules.sys.enums.Permission;
import org.bjf.modules.sys.query.SysMenuQuery;
import org.bjf.modules.sys.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin")
@Permission(resSn = "user", resDesc = "用户管理 ")
public class SysMenuController {

  @Autowired
  private SysMenuService menuService;

  @RequestMapping("memnu/detail")
  @LoginRequired
  public SysMenu detail(@RequestParam long sysMenuId) {
    return menuService.get(sysMenuId);
  }

  @RequestMapping("memnu/list")
  public List<SysMenu> list(SysMenuQuery query) {
    return menuService.list(query);
  }

  @RequestMapping("memnu/listPage")
  public PageVO<SysMenu> listPage(SysMenuQuery query) {
    return menuService.listPage(query);
  }

  @RequestMapping("memnu/listAll")
  public List<SysMenu> listAll(SysMenuQuery query) {
    return menuService.listAll(query);
  }


  @RequestMapping("memnu/add")
  public void add(@Validated SysMenu menu) {
    menuService.add(menu);
  }

  @RequestMapping("memnu/update")
  public void update(@Validated SysMenu menu) {
    menuService.updateById(menu);
  }

  @RequestMapping("memnu/delete")
  public void delete(@RequestParam long sysMenuId) {
    menuService.deleteById(sysMenuId);
  }
}
